หลักการพื้นฐานของวิศวกรรมคำสั่ง
วิศวกรรมคำสั่ง (PE) คือกระบวนการในการออกแบบและปรับแต่งข้อความเพื่อนำทางโมเดลภาษาขนาดใหญ่ (LLM) ไปสู่ผลลัพธ์ที่มีคุณภาพสูงและมีความสม่ำเสมอ
1. กำหนดหน้าต่างป้อนข้อมูล
อะไร: มันทำหน้าที่เป็นหน้าต่างป้อนข้อมูลหลักสำหรับปัญญาประดิษฐ์สร้างเนื้อหา
ทำไม: มันเปลี่ยนการโต้ตอบจากพยากรณ์ข้อความที่ไม่แน่นอนและหยาบง่าย มาเป็นการดำเนินการตามคำสั่งอย่างตั้งใจและเป็นโครงสร้าง
2. พื้นฐานของโมเดล
- โมเดลพื้นฐาน LLMs: ฝึกอบรมเพียงเพื่อคาดการณ์โทเค็นถัดไปโดยอิงจากความสัมพันธ์ทางสถิติในชุดข้อมูลขนาดใหญ่ โดยเพิ่มความน่าจะเป็นให้สูงสุด $P(w_t | w_1, w_2, ..., w_{t-1})$
- โมเดลที่ปรับแต่งคำสั่ง (Instruction-Tuned LLMs): ปรับแต่งอย่างละเอียดผ่านการเรียนรู้เสริมด้วยข้อเสนอแนะจากมนุษย์ (RLHF) เพื่อปฏิบัติตามคำสั่งเฉพาะเจาะจงอย่างชัดเจน และทำหน้าที่เป็นผู้ช่วยที่เป็นประโยชน์
3. องค์ประกอบของคำสั่งที่ประสบความสำเร็จ
อย่างไร: คำสั่งที่แข็งแรงมักประกอบด้วย:
- คำสั่ง: การกระทำเฉพาะเจาะจงที่ต้องการ
- เนื้อหาหลัก: ข้อมูลเป้าหมายที่ต้องการประมวลผล
- เนื้อหาเสริม: พารามิเตอร์ การจัดรูปแบบ หรือข้อจำกัด (เพื่อแก้ไขปัญหาความสุ่มและความเข้าใจผิด)
ความจริงเกี่ยวกับการแบ่งโทเค็น
โมเดลไม่ได้อ่านคำ แต่พวกเขาประมวลผล โทเค็น—หน่วยย่อยของลำดับข้อความที่ใช้คำนวณความน่าจะเป็นทางสถิติ
TERMINALbash — 80x24
> Ready. Click "Run" to execute.
>
Question 1
What is the primary difference between a Base LLM and an Instruction-Tuned LLM?
Question 2
Why is the use of delimiters (like triple backticks or hashes) considered a best practice in prompt engineering?
Challenge: Tutor AI Constraints
Refining prompts for educational safety.
You are building a tutor-style AI for a startup. The model is currently giving away answers too quickly and sometimes making up facts when it doesn't know the answer.
Task 1
Implement "Chain-of-thought" prompting in the system message to prevent the AI from giving away answers immediately.
Solution:
Instruct the model to:
Instruct the model to:
"Work through the problem step-by-step before providing the final answer. Do not reveal the final answer until the student has attempted the steps."Task 2
Apply an "out" to prevent fabrications (hallucinations) when the AI doesn't know the answer.
Solution:
Add the explicit instruction:
Add the explicit instruction:
"If you do not know the answer based on the provided text or standard curriculum, state clearly that you do not know."